﻿package server;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ComActionList extends UnicastRemoteObject implements ComActionInterface{

	
	private Data data;
	public ComActionList() throws RemoteException{
		data=new Data();
	}
	
	public String action;
	public int HP;
	public int Hap;

	public int getHP(String ac) throws RemoteException{
		String sql;
		ResultSet rs=null;
		int HP=0;
		
		sql="select * from comwork where action='" + ac +"'";
		rs=data.getResultSet(sql);
		try {
			while(rs.next()){
				HP=rs.getInt("hp");
		      }
			} catch (SQLException e) {
		
			e.printStackTrace();
			}
		return HP;
	}
	

	

	public int getHap(String ac) throws RemoteException{
		String sql;
		ResultSet rs=null;
		int Hap=0;
		
		sql="select * from comwork where action='" + ac +"'";
		rs=data.getResultSet(sql);
		try {
			while(rs.next()){
				Hap=rs.getInt("hap");
		}
			} catch (SQLException e) {
		
			e.printStackTrace();
			}
		return Hap;
	}
	
	public int getSize() throws RemoteException{
		String sql;
		ResultSet rs=null;
		int sum=0;
		
		sql="select count(*) as sum from comwork";
		rs=data.getResultSet(sql);
		try {
			while(rs.next()){
				sum=rs.getInt("sum");
		}
			} catch (SQLException e) {
		
			e.printStackTrace();
			}
		return sum;
	}

}
